Attribute VB_Name = "modODBCSanofi"
'---------------------------------------------------------------------------------------
'Module     : modODBC
'Author     : Joseph Weir
'Purpose    : Sanofi.
'
' 2010-05-26, JFW, Text file import as in Sanofi.
'
'---------------------------------------------------------------------------------------
Option Explicit

#If Sanofi Then

Dim m_CNIn As ADODB.Connection
Dim m_CNOut As ADODB.Connection
Dim m_RS As ADODB.Recordset
Dim m_strLine As String
Dim mstrIMPORT_FILE_PATH As String
Dim mobjFSO As FileSystemObject
'


'---------------------------------------------------------------------------------------
' Procedure : AfterAddrLookup()
' DateTime  : 2/21/2005
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             cboCustID, cboContact, or cboCompany loses focus.
'---------------------------------------------------------------------------------------
'
Public Sub AfterAddrLookup()
    frmShip.f25.SetFocus
End Sub

'---------------------------------------------------------------------------------------
' Procedure : AfterAddrVerify()
' DateTime  : 5/12/2006
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             Address Verification. Three possible status codes are passed. See comments
'             below.
'---------------------------------------------------------------------------------------
'
Public Sub AfterAddrVerify(ByVal intStatusCode As Integer)

    Select Case intStatusCode
        'Address is verfified
        Case 1

        'Soft error
        Case 2

        'Hard error
        Case 3

    End Select

End Sub

'---------------------------------------------------------------------------------------
' Procedure : AfterAddrVerifyUpdate()
' DateTime  : 9/13/2005
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             an address has been updated on the Ship form.
'---------------------------------------------------------------------------------------
'
Public Sub AfterAddrVerifyUpdate()

End Sub

'---------------------------------------------------------------------------------------
' Procedure : AfterBatch()
' DateTime  : 4/6/2005
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             a batch shipment has been completed.
'---------------------------------------------------------------------------------------
'
Public Sub AfterBatch()

End Sub

'---------------------------------------------------------------------------------------
' Procedure : AfterBatchShip()
' DateTime  : 10/28/2005
' Purpose   : REQUIRED SUB. Called just after a batch transaction has been processed.
'---------------------------------------------------------------------------------------
'
Public Sub AfterBatchShip()

End Sub

'---------------------------------------------------------------------------------------
' Procedure : AfterDeptLostFocus()
' DateTime  : 2/21/2005
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             f38 loses focus.
'---------------------------------------------------------------------------------------
'
Public Sub AfterDeptLostFocus()

    On Error Resume Next
    g_clsReg.SetRegistryValue "Carry_f38", frmShip.f38, REG_SZ

End Sub

'---------------------------------------------------------------------------------------
' Procedure : AfterLocationChange()
' DateTime  : 3/06/2006
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             the shipping Location has been changed on the Ship form.
'---------------------------------------------------------------------------------------
'
Public Sub AfterLocationChange()

End Sub

'---------------------------------------------------------------------------------------
' Procedure : AfterClose()
' DateTime  : 7/5/2004
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             FXRS Close.
'---------------------------------------------------------------------------------------
'
Public Sub AfterClose()

End Sub
'

' 2007-04-13, JFW, Allow for custom screen display.
Public Sub AfterConnect()

    ' 2007-12-07, JFW, Large address book making a slow start on some clients.
    ' Call frmShip.ToggleLookup(True)
    On Error Resume Next
    'Call frmShip.ToggleDepartment(True)
    frmShip.f70.ListIndex = 0
    frmShip.f72.ListIndex = 0
    frmShip.f38 = g_clsReg.GetRegistryValue("Carry_f38", "")
    frmShip.f75 = g_clsReg.GetRegistryValue("Carry_f75", "")
    frmShip.f1274 = g_clsReg.GetRegistryValue("Carry_f1274", "")

End Sub
'

' 2011-07-10, JFW, New interface to clear DG disclaimer automatically.
Public Function AfterDGDisclaimer() As Boolean
    AfterDGDisclaimer = False
End Function
'

' 2007-04-13, JFW, Allow for custom screen display.
Public Sub AfterDisconnect()

    On Error Resume Next
    
End Sub
'

'---------------------------------------------------------------------------------------
' Procedure : AfterLoadServices()
' DateTime  : 5/17/2011
' Purpose   : Remove or add custom services.
' 2011-05-17, JFW, New for Scapa
'---------------------------------------------------------------------------------------
'
Public Sub AfterLoadServices(c1 As ComboBox)

End Sub
'

'---------------------------------------------------------------------------------------
' Procedure : AfterLostFocus()
' DateTime  : 2/21/2005
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             cboDept or f38 loses focus.
'---------------------------------------------------------------------------------------
'
Public Sub AfterLostFocus(c1 As Control)

    If c1.name = "f38" Then
        'g_clsReg.SetRegistryValue "Carry_f38", frmShip.f38, REG_SZ
    End If
    If c1.name = "f1273" Then
        'g_clsReg.SetRegistryValue "Carry_f1273", Left(frmShip.f1273.Text, 2), REG_SZ
    End If

End Sub
'

'---------------------------------------------------------------------------------------
' Procedure : AfterRateQuote()
' DateTime  : 20071106-01
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             a rate quote.
'---------------------------------------------------------------------------------------
'
Public Sub AfterRateQuote()

End Sub

' 2012-01-19, JFW, New for UCS.
Public Function AfterScreenChange(f As Form) As Boolean

End Function
'

'---------------------------------------------------------------------------------------
' Procedure : BeforeBatch()
' DateTime  : 20070621-01 Changed BeforeBatch to return a boolean
' Purpose   : REQUIRED SUB. Called before an entire batch is processed.
'---------------------------------------------------------------------------------------
'
Public Function BeforeBatch() As Boolean

    BeforeBatch = True

End Function
'---------------------------------------------------------------------------------------
' Procedure : BeforeBatchShip()
' DateTime  : 20070822-02 Modified BeforeBatchShip to return a Boolean.
' Purpose   : REQUIRED SUB. Called just before a batch transaction is sent to the server.
'---------------------------------------------------------------------------------------
'
Public Function BeforeBatchShip() As Boolean

    BeforeBatchShip = True

End Function

' 2012-01-19, JFW, New for UCS.
Public Function BeforeGotFocus(f As Form, c As Control) As Boolean
    On Error GoTo Test
    Exit Function
Test:
    DebugPrint "BeforeGotFocus, " & Err.Description
    
End Function
'

'---------------------------------------------------------------------------------------
' Procedure : BeforeClose()
' DateTime  : 7/12/2006
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed before
'             FXRS Close.
'---------------------------------------------------------------------------------------
'
Public Function BeforeClose() As Boolean

    BeforeClose = True

End Function
'

'---------------------------------------------------------------------------------------
' Procedure : BeforeShip()
' DateTime  : 2/21/2005
' Purpose   : REQUIRED Function. Modified to Return Boolean which controls whether or not
'             the shipment will continue or be canceled. Return True to continue shipment,
'             False to cancel.
'---------------------------------------------------------------------------------------
'
Public Function BeforeShip(Optional ByRef TransString As String = "") As Boolean

    BeforeShip = True

    If frmShip.f25 = "" Then
        MsgBox "Reference is mandatory.", vbApplicationModal + vbSystemModal
        frmShip.SSTab1.Tab = 0
        frmShip.f25.SetFocus
        BeforeShip = False
    End If

End Function
'

'---------------------------------------------------------------------------------------
' Procedure : BeforeShipTrans()
' DateTime  : 8/7/2008
' Purpose   : REQUIRED Function. Modified to Return Boolean which controls whether or not
'             the shipment will continue or be canceled. Return True to continue shipment,
'             False to cancel.
'---------------------------------------------------------------------------------------
'
Public Function BeforeShipTrans(ByRef TransString As String) As Boolean
    
    Dim lngMsgBoxResult As VbMsgBoxResult
    
    ' DG
    If 0 <> InStr(1, TransString, """1903,""") Then
        If GetSystemName = "WINXPC9CA96EA3" _
        Or GetSystemName = "CAN00335113" _
        Or GetSystemName = "WIN7FSMSCLIENT" Then
            ' DG item
            ' TransString = "0,""020""1,""TESTBC""1221-1,""Y""1222-1,""486833784550""1223-1,""0430""50,""CA""12,""Test only""13,""123 any st""15,""VANCOUVER""16,""BC""17,""V5Z 2M9""18,""1235551243""26,""0""32,""Test TD""4,""SCAPA TEST TD""5,""609 BARNET BLVD""7,""RENFREW""8,""ON""9,""K7V3Z4""117,""CA""183,""1235551234""1670,""1000""75,""LBS""1274,""01""1273,""01""24,""20120612""68,""CAD""23,""1""25,""test""38,""Accounting""1331-1,""A""451-1,""1791""456-1,""1""461-1,""0.5 L""466-1,""1""471-1,""L""476-1,""Y840""488-1,""N""489-1,""II""1903-1,""Hypochlorite solution""1331-2,""A""451-2,""1783""456-2,""1""461-2,""1  L""466-2,""1""471-2,""L""476-2,""851""488-2,""N""489-2,""II""1903-2,""Hexamethylenediamine solution""1932,""2""1918,""JFW""1922,""Toronto""484,""1235551234""485,""JFW""187,""188""537,""\\127.0.0.1\ZebraZ2B""1370,""3""1282,""T""10,""141415719""498,""839225""116,""1""75,""LBS""26,""0""1621,""486833784550""116,""2""1670-1,""1100""1670-2,""1200""99,"""""
            
            ' UNC DG form
            ' TransString = Replace(TransString, "99,""""", "1493,""Y""1373,""40""1679,""\\127.0.0.1\RICOH_YYZHQ""1680,""02""99,""""")
            
            ' pRINTER
            ' TransString = Replace(TransString, "99,""""", "1493,""Y""1373,""40""1679,""Send To OneNote 2010#:1""1680,""02""99,""""")
'
        End If
    End If
    
    BeforeShipTrans = True
    
End Function
'

'---------------------------------------------------------------------------------------
' Procedure : BuildCustomSPLabel()
' DateTime  : 20070620-04
' Purpose   : REQUIRED SUB. Can be used as hook to create custom EPL or ZPL buffer labels
'             for SmartPost.
'---------------------------------------------------------------------------------------
'
Public Function BuildCustomSPLabel(ByVal strLabel As String) As String

    BuildCustomSPLabel = strLabel

End Function

Public Function ClearCommodity() As Boolean

End Function
'

Public Function ClearShipScreen() As Boolean

    On Error Resume Next
    frmShip.f38 = g_clsReg.GetRegistryValue("Carry_f38", "")
    frmShip.f75 = g_clsReg.GetRegistryValue("Carry_f75", "")
    frmShip.f1274 = g_clsReg.GetRegistryValue("Carry_f1274", "")

End Function
'

'---------------------------------------------------------------------------------------
' Procedure : Connect()
' DateTime  : 7/5/2004
' Purpose   : Open connection to ODBC test DSN. Instantiate module level recordset.
'---------------------------------------------------------------------------------------
'
Private Function Connect() As Boolean
    On Local Error GoTo Handler
    Dim strDSN As String
    Dim boolSecondTry As Boolean

    If m_CNIn Is Nothing Then
        Set m_CNIn = New ADODB.Connection
    End If
    If m_CNOut Is Nothing Then
        Set m_CNOut = New ADODB.Connection
    End If
    Set m_RS = New ADODB.Recordset

    Connect = True

    Exit Function

Handler:
'    If Not boolSecondTry Then
'        boolSecondTry = True
'        If Err.number = -2147467259 Then
'            Call AddDSN
'            Resume
'        End If
'    End If
    MsgBox Err.Description, , "modODBC.Connect"
    ' Call Kill        'kill connection and recordset

End Function
'

'---------------------------------------------------------------------------------------
' Procedure : GetData()
' DateTime  : 7/5/2004
' Purpose   : REQUIRED SUB. Called from frmShip.f1_LostFocus, which is the OrderID field.
'             Call routines needed to get data from the customer's system and assign the
'             value to the appropriate fields on the Ship form. This example uses ODBC.
'---------------------------------------------------------------------------------------
'
Public Function GetData(ByVal strKey As String) As Boolean
    On Local Error GoTo Handler
    Dim strSelect As String
    Dim strUserPwd As String    'DSN user and password separated by ','
    Dim strUser As String       'DSN user name
    Dim strPwd As String        'DSN user password
    Dim strData As String
    Dim i As Long

'    If g_clsReg.GetRegistryValue("IntegrationLevel", "Writeback") <> "Writeback" _
'    And g_clsReg.GetRegistryValue("IntegrationLevel", "Writeback") <> "Order Lookup" Then
'        GetData = True
'        Exit Function
'    End If

    If m_CNIn Is Nothing Then
        Call Connect
    End If

    ' frmShip.cboCustID = strKey

    If GetDataText(strKey) Then
        GetData = True
        frmShip.f25.SetFocus
    ElseIf LoadAddrFields("CustID", strKey, frmShip) Then
        GetData = True
        frmShip.f25.SetFocus
    Else

    End If

    Call DeleteIntlCommodities(strKey)

Release:
    ' call kill
    Exit Function
Handler:
    MsgBox Err.Description, , "modODBC.GetData"
    ' Call Kill
    Resume Release

End Function
'

'---------------------------------------------------------------------------------------
' Procedure : GetDataText()
' DateTime  : 7/5/2004
' Purpose   : REQUIRED SUB. Called from frmShip.f1_LostFocus, which is the OrderID field.
'             Call routines needed to get data from the customer's system and assign the
'             value to the appropriate fields on the Ship form. This example uses ODBC.
'---------------------------------------------------------------------------------------
'
Public Function GetDataText(ByVal strKey As String) As Boolean

    On Local Error GoTo Handler

    Dim i As Long
    Dim intRecordCurrent As Long
    Dim strEmail As String
    Dim strZip As String
    Dim strRecords() As String

    If mstrIMPORT_FILE_PATH = "" Then
        mstrIMPORT_FILE_PATH = g_clsSettings.Setting("IntegrationFolder")
        If mstrIMPORT_FILE_PATH = "" Then
            If GetSystemName = "CAN00283812" Then
                g_clsSettings.Setting("IntegrationFolder") = "C:\Documents and Settings\271425\My Documents\CUSTOMERDATA\CUSTOMERDATA\ElectroSonic\"
            ElseIf GetSystemName = "WINXPC9CA96EA3" Then
                g_clsSettings.Setting("IntegrationFolder") = "C:\Documents and Settings\563774\My Documents\FXI\Projects\AAA Maintenance\Sanofi\"
            Else
                g_clsSettings.Setting("IntegrationFolder") = "Z:\OUTBOUND\"
            End If
            g_clsSettings.SaveSettings
            mstrIMPORT_FILE_PATH = g_clsSettings.Setting("IntegrationFolder")
            frmMsgBox.ShowMessage "Configuration file (FSMSClient.xml) updated with IntegrationFolder.", 8000
        End If
    End If
    
    If mobjFSO Is Nothing Then Set mobjFSO = New FileSystemObject

    If mobjFSO.FileExists(mstrIMPORT_FILE_PATH & strKey & ".csv") Then
        strRecords = RecordImport2(mstrIMPORT_FILE_PATH, strKey & ".csv", "", ",")
    
        With frmShip
            .f23.Text = 1
            .f3056.Text = strKey
            .f3057.Text = strRecords(0, intRecordCurrent)
            
            .f11.Text = strRecords(2, intRecordCurrent)
            .f12.Text = strRecords(1, intRecordCurrent)
            .f13.Text = strRecords(3, intRecordCurrent)
            ' .f14.Text = strRecords(4, intRecordCurrent)
            .f15.Text = strRecords(4, intRecordCurrent)
            .f16.Text = strRecords(5, intRecordCurrent)
            .f17.Text = strRecords(6, intRecordCurrent)
            .f18.Text = strRecords(8, intRecordCurrent)
            .f50.Text = strRecords(7, intRecordCurrent)
    
        End With
    
        GetDataText = True
    End If
    
Release:
    Exit Function
Handler:
    MsgBox Err.Description, , "modODBC.GetDataText"
    Resume Release

End Function
'

'---------------------------------------------------------------------------------------
' Procedure : GetPickupData()
' DateTime  : 1/30/2006
' Purpose   : REQUIRED SUB. Called from frmAddTags.f1_LostFocus, which is the OrderID field.
'             Call routines needed to get data from the customer's system and assign the
'             value to the appropriate fields on the Ship form. This example uses ODBC.
'---------------------------------------------------------------------------------------
'
Public Function GetPickupData(ByVal strKey As String) As Boolean

    GetPickupData = True

End Function
'

'---------------------------------------------------------------------------------------
' Procedure : Initialize()
' DateTime  : 7/5/2004
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed on
'             program execution.
'---------------------------------------------------------------------------------------
'
Public Sub Initialize(Optional f1 As Form)

End Sub


' 2011-05-05, JFW, For Scapa
Public Function TDAutoCloseEnabled() As Boolean
    TDAutoCloseEnabled = False
End Function
'

'---------------------------------------------------------------------------------------
' Procedure : WriteReply()
' DateTime  : 2/14/2005
' Purpose   : REQUIRED SUB. Called after a successful ship transaction.
'             This example shows how to obtain multiple occurrence fields from the
'             FXRS reply and how to obtain multiple occurrence fields included in the
'             input transaction but not returned in the FXRS reply.
'---------------------------------------------------------------------------------------
'
Public Sub WriteReply()

    On Local Error GoTo Handler


    If frmShip.f1.Visible = True Then
        Call frmShip.SaveAddress(frmShip.f1)
    End If

    'g_strErrorLocation = "Done"

Release:
    Exit Sub

Handler:
    MsgBox "Error, " & Err.Description, , "modODBC.WriteReply"
    'Call Kill
    Resume Release


End Sub
'---------------------------------------------------------------------------------------
' Procedure : WriteReturnReply()
' DateTime  : 7/14/2005
' Purpose   : REQUIRED SUB. Called after a successful return label transaction.
'             This is called for both regular and online return labels.
'---------------------------------------------------------------------------------------
'
Public Sub WriteReturnReply()

End Sub
'---------------------------------------------------------------------------------------
' Procedure : WriteBOLReply()
' DateTime  : 1/11/2006
' Purpose   : REQUIRED SUB. Called after a successful FedEx Freight BOL transaction.
'             This is called for both regular and online return labels.
'---------------------------------------------------------------------------------------
'
Public Sub WriteBOLReply()

End Sub
'---------------------------------------------------------------------------------------
' Procedure : WriteBatchEditReply()
' DateTime  : 1/17/2006
' Purpose   : REQUIRED SUB. Called after a successful Batch Error Edit transaction.
'             This is called for both regular and online return labels.
'---------------------------------------------------------------------------------------
'
Public Sub WriteBatchEditReply()

End Sub
' Procedure : WriteTagReply()
' DateTime  : 1/26/2006
' Purpose   : REQUIRED SUB. Called after a successful Call Tag/Express Tag transaction.
'---------------------------------------------------------------------------------------
'
Public Sub WriteTagReply()

End Sub
' Procedure : WriteCancelTagReply()
' DateTime  : 1/26/2006
' Purpose   : REQUIRED SUB. Called after a successful Cancel Call Tag/Express Tag transaction.
'---------------------------------------------------------------------------------------
'
Public Sub WriteCancelTagReply()

End Sub
'---------------------------------------------------------------------------------------
' Procedure : WriteReturnDelete()
' DateTime  : 7/14/2005
' Purpose   : REQUIRED SUB. Called after a successful return label delete transaction.
'             This is called for both regular and online return labels.
'---------------------------------------------------------------------------------------
'
Public Sub WriteReturnDelete(ByVal strTracking As String)

End Sub
'---------------------------------------------------------------------------------------
' Procedure : WriteError()
' DateTime  : 7/5/2004
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             an FXRS Error reply transaction.
'---------------------------------------------------------------------------------------
'
Public Sub WriteError()
    MsgBox "Shipping Error: " & g_str3, vbCritical, "FSMS Error"
End Sub
'---------------------------------------------------------------------------------------
' Procedure : WriteDelete()
' DateTime  : 7/5/2004
' Purpose   : REQUIRED SUB. Can be used as hook to call routines to be executed after
'             successful FXRS Delete.
' Called    : frmShip g_clsParser_Parsecomplete() event on FSMS 123 reply
'---------------------------------------------------------------------------------------
'
Public Sub WriteDelete(ByVal strTracking As String)

End Sub





#End If



